package com.dongdongshop.config;

import com.dongdongshop.job.SeckillJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {

    @Bean
    public JobDetail jobDetail(){
        return JobBuilder.newJob(SeckillJob.class)
                .withIdentity("jobName1","jobGroup")
                .storeDurably()//group 组名,name值在这个组中必须唯一
                .build();
    }
    @Bean
    public Trigger trigger() {
        CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0/3 * * * * ?");
        return TriggerBuilder.newTrigger().forJob(jobDetail()).withSchedule(cronScheduleBuilder).build();
    }
}
